package helperClassPassMarkers;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class CreateMyMessages {
	
	public static void createMyMessages(String fileName, int xlsSheet1, int xlsSheet2, int xlsSheet3, int xlsSheet4, int xlsSheet5, int xlsSheet6,int xlsSheet7,int xlsSheet8,int xlsSheet9,int xlsSheet10,int xlsSheet11,int xlsSheet12, String packageName, String className, boolean cycled) {
	
		File replacedFile = new File(fileName);
		replacedFile.delete();
		
	    try {
	    	Workbook workbook = Workbook.getWorkbook(new File("C:\\Documents and Settings\\Administrator\\My Documents\\Dropbox\\CTA\\XLS\\CTA.xls"));

	    	FileWriter fstream = new FileWriter(fileName);
	    	BufferedWriter textFile = new BufferedWriter(fstream);
	    	
	    	textFile.write("package com.cyclingthealps." + packageName +";\n");
	    	textFile.write("\n");
	    	textFile.write("import com.google.gwt.i18n.client.Messages;\n");
	    	textFile.write("\n");
	    	textFile.write("public interface " + className + " extends Messages {\n"); 
	    	textFile.write("\n");
	    	
	    	Sheet sheet = workbook.getSheet(xlsSheet1);
	    	Cell[] count = sheet.getColumn(0);	    	
	       	for (int i = 1; i < count.length; i++) {
		        Cell passNameCell = sheet.getCell(3,i);
		        String passName = passNameCell.getContents();
		        textFile.write("String " + passName + "();" + "\n");
	       	}
	       	for (int j = 1; j < count.length; j++) {
		        Cell passDescriptionCell = sheet.getCell(10, j);
		        String passDescription = passDescriptionCell.getContents();
		        textFile.write("String " + passDescription + "();" + "\n");
	       	}
	       	for (int l = 1; l < count.length; l++) {
		        Cell passWebelementCell = sheet.getCell(17, l);
		        String passWebelement = passWebelementCell.getContents();
		        textFile.write("String " + passWebelement + "();" + "\n");
	       	}
	       	for (int k = 1; k < count.length; k++) {
		        Cell passLinkCell = sheet.getCell(34, k);
		        String passLink = passLinkCell.getContents();
		        textFile.write("String " + passLink + "();" + "\n");
	       	}
	       	for (int l = 1; l < count.length; l++) {
		        Cell passOracleCell = sheet.getCell(40, l);
		        String passOracle = passOracleCell.getContents();
		        textFile.write("String " + passOracle + "();" + "\n");
	       	}
	       	textFile.write("\n");
	       	if (xlsSheet2 > 0  ){
		    	Sheet sheet2 = workbook.getSheet(xlsSheet2);
		    	Cell[] count2 = sheet2.getColumn(0);
		       	for (int i = 1; i < count2.length; i++) {
			        Cell passNameCell = sheet2.getCell(3,i);
			        String passName = passNameCell.getContents();
			        textFile.write("String " + passName + "();" + "\n");
		       	}
		       	for (int j = 1; j < count2.length; j++) {
			        Cell passDescriptionCell = sheet2.getCell(10, j);
			        String passDescription = passDescriptionCell.getContents();
			        textFile.write("String " + passDescription + "();" + "\n");
		       	}
		       	for (int l = 1; l < count2.length; l++) {
			        Cell passWebelementCell = sheet2.getCell(17, l);
			        String passWebelement = passWebelementCell.getContents();
			        textFile.write("String " + passWebelement + "();" + "\n");
		       	}
		       	for (int k = 1; k < count2.length; k++) {
			        Cell passLinkCell = sheet2.getCell(34, k);
			        String passLink = passLinkCell.getContents();
			        textFile.write("String " + passLink + "();" + "\n");
		       	}
		       	for (int l = 1; l < count2.length; l++) {
			        Cell passOracleCell = sheet2.getCell(40, l);
			        String passOracle = passOracleCell.getContents();
			        textFile.write("String " + passOracle + "();" + "\n");
		       	}
	       	}
	       	textFile.write("\n");
	       	if (xlsSheet3 > 0  ){
		    	Sheet sheet3 = workbook.getSheet(xlsSheet3);
		    	Cell[] count3 = sheet3.getColumn(0);
		       	for (int i = 1; i < count3.length; i++) {
			        Cell passNameCell = sheet3.getCell(3,i);
			        String passName = passNameCell.getContents();
			        textFile.write("String " + passName + "();" + "\n");
		       	}
		       	for (int j = 1; j < count3.length; j++) {
			        Cell passDescriptionCell = sheet3.getCell(10, j);
			        String passDescription = passDescriptionCell.getContents();
			        textFile.write("String " + passDescription + "();" + "\n");
		       	}
		       	for (int l = 1; l < count3.length; l++) {
			        Cell passWebelementCell = sheet3.getCell(17, l);
			        String passWebelement = passWebelementCell.getContents();
			        textFile.write("String " + passWebelement + "();" + "\n");
		       	}
		       	for (int k = 1; k < count3.length; k++) {
			        Cell passLinkCell = sheet3.getCell(34, k);
			        String passLink = passLinkCell.getContents();
			        textFile.write("String " + passLink + "();" + "\n");
		       	}
		       	for (int l = 1; l < count3.length; l++) {
			        Cell passOracleCell = sheet3.getCell(40, l);
			        String passOracle = passOracleCell.getContents();
			        textFile.write("String " + passOracle + "();" + "\n");
		       	}
	       	}
	       	textFile.write("\n");
	       	if (xlsSheet4 > 0  ){
		    	Sheet sheet4 = workbook.getSheet(xlsSheet4);
		    	Cell[] count4 = sheet4.getColumn(0);
		       	for (int i = 1; i < count4.length; i++) {
			        Cell passNameCell = sheet4.getCell(3,i);
			        String passName = passNameCell.getContents();
			        textFile.write("String " + passName + "();" + "\n");
		       	}
		       	for (int j = 1; j < count4.length; j++) {
			        Cell passDescriptionCell = sheet4.getCell(10, j);
			        String passDescription = passDescriptionCell.getContents();
			        textFile.write("String " + passDescription + "();" + "\n");
		       	}
		       	for (int l = 1; l < count4.length; l++) {
			        Cell passWebelementCell = sheet4.getCell(17, l);
			        String passWebelement = passWebelementCell.getContents();
			        textFile.write("String " + passWebelement + "();" + "\n");
		       	}
		       	for (int k = 1; k < count4.length; k++) {
			        Cell passLinkCell = sheet4.getCell(34, k);
			        String passLink = passLinkCell.getContents();
			        textFile.write("String " + passLink + "();" + "\n");
		       	}
		       	for (int l = 1; l < count4.length; l++) {
			        Cell passOracleCell = sheet4.getCell(40, l);
			        String passOracle = passOracleCell.getContents();
			        textFile.write("String " + passOracle + "();" + "\n");
		       	}
	       	}
	       	if (xlsSheet5 > 0  ){
		    	Sheet sheet5 = workbook.getSheet(xlsSheet5);
		    	Cell[] count5 = sheet5.getColumn(0);
		       	for (int i = 1; i < count5.length; i++) {
			        Cell passNameCell = sheet5.getCell(3,i);
			        String passName = passNameCell.getContents();
			        textFile.write("String " + passName + "();" + "\n");
		       	}
		       	for (int j = 1; j < count5.length; j++) {
			        Cell passDescriptionCell = sheet5.getCell(10, j);
			        String passDescription = passDescriptionCell.getContents();
			        textFile.write("String " + passDescription + "();" + "\n");
		       	}
		       	for (int l = 1; l < count5.length; l++) {
			        Cell passWebelementCell = sheet5.getCell(17, l);
			        String passWebelement = passWebelementCell.getContents();
			        textFile.write("String " + passWebelement + "();" + "\n");
		       	}
		       	for (int k = 1; k < count5.length; k++) {
			        Cell passLinkCell = sheet5.getCell(34, k);
			        String passLink = passLinkCell.getContents();
			        textFile.write("String " + passLink + "();" + "\n");
		       	}
		       	for (int l = 1; l < count5.length; l++) {
			        Cell passOracleCell = sheet5.getCell(40, l);
			        String passOracle = passOracleCell.getContents();
			        textFile.write("String " + passOracle + "();" + "\n");
		       	}
	       	}
	       	if (xlsSheet6 > 0  ){
		    	Sheet sheet6 = workbook.getSheet(xlsSheet6);
		    	Cell[] count6 = sheet6.getColumn(0);
		       	for (int i = 1; i < count6.length; i++) {
			        Cell passNameCell = sheet6.getCell(3,i);
			        String passName = passNameCell.getContents();
			        textFile.write("String " + passName + "();" + "\n");
		       	}
		       	for (int j = 1; j < count6.length; j++) {
			        Cell passDescriptionCell = sheet6.getCell(10, j);
			        String passDescription = passDescriptionCell.getContents();
			        textFile.write("String " + passDescription + "();" + "\n");
		       	}
		       	for (int l = 1; l < count6.length; l++) {
			        Cell passWebelementCell = sheet6.getCell(17, l);
			        String passWebelement = passWebelementCell.getContents();
			        textFile.write("String " + passWebelement + "();" + "\n");
		       	}
		       	for (int k = 1; k < count6.length; k++) {
			        Cell passLinkCell = sheet6.getCell(34, k);
			        String passLink = passLinkCell.getContents();
			        textFile.write("String " + passLink + "();" + "\n");
		       	}
		       	for (int l = 1; l < count6.length; l++) {
			        Cell passOracleCell = sheet6.getCell(40, l);
			        String passOracle = passOracleCell.getContents();
			        textFile.write("String " + passOracle + "();" + "\n");
		       	}
	       	}
	       	if (xlsSheet7 > 0  ){
		    	Sheet sheet7 = workbook.getSheet(xlsSheet7);
		    	Cell[] count7 = sheet7.getColumn(0);
		       	for (int i = 1; i < count7.length; i++) {
			        Cell passNameCell = sheet7.getCell(3,i);
			        String passName = passNameCell.getContents();
			        textFile.write("String " + passName + "();" + "\n");
		       	}
		       	for (int j = 1; j < count7.length; j++) {
			        Cell passDescriptionCell = sheet7.getCell(10, j);
			        String passDescription = passDescriptionCell.getContents();
			        textFile.write("String " + passDescription + "();" + "\n");
		       	}
		       	for (int l = 1; l < count7.length; l++) {
			        Cell passWebelementCell = sheet7.getCell(17, l);
			        String passWebelement = passWebelementCell.getContents();
			        textFile.write("String " + passWebelement + "();" + "\n");
		       	}
		       	for (int k = 1; k < count7.length; k++) {
			        Cell passLinkCell = sheet7.getCell(34, k);
			        String passLink = passLinkCell.getContents();
			        textFile.write("String " + passLink + "();" + "\n");
		       	}
		       	for (int l = 1; l < count7.length; l++) {
			        Cell passOracleCell = sheet7.getCell(40, l);
			        String passOracle = passOracleCell.getContents();
			        textFile.write("String " + passOracle + "();" + "\n");
		       	}
	       	}
	       	if (xlsSheet8 > 0  ){
		    	Sheet sheet8 = workbook.getSheet(xlsSheet8);
		    	Cell[] count8 = sheet8.getColumn(0);
		       	for (int i = 1; i < count8.length; i++) {
			        Cell passNameCell = sheet8.getCell(3,i);
			        String passName = passNameCell.getContents();
			        textFile.write("String " + passName + "();" + "\n");
		       	}
		       	for (int j = 1; j < count8.length; j++) {
			        Cell passDescriptionCell = sheet8.getCell(10, j);
			        String passDescription = passDescriptionCell.getContents();
			        textFile.write("String " + passDescription + "();" + "\n");
		       	}
		       	for (int l = 1; l < count8.length; l++) {
			        Cell passWebelementCell = sheet8.getCell(17, l);
			        String passWebelement = passWebelementCell.getContents();
			        textFile.write("String " + passWebelement + "();" + "\n");
		       	}
		       	for (int k = 1; k < count8.length; k++) {
			        Cell passLinkCell = sheet8.getCell(34, k);
			        String passLink = passLinkCell.getContents();
			        textFile.write("String " + passLink + "();" + "\n");
		       	}
		       	for (int l = 1; l < count8.length; l++) {
			        Cell passOracleCell = sheet8.getCell(40, l);
			        String passOracle = passOracleCell.getContents();
			        textFile.write("String " + passOracle + "();" + "\n");
		       	}
	       	}
	       	if (xlsSheet9 > 0  ){
		    	Sheet sheet9 = workbook.getSheet(xlsSheet9);
		    	Cell[] count9 = sheet9.getColumn(0);
		       	for (int i = 1; i < count9.length; i++) {
			        Cell passNameCell = sheet9.getCell(3,i);
			        String passName = passNameCell.getContents();
			        textFile.write("String " + passName + "();" + "\n");
		       	}
		       	for (int j = 1; j < count9.length; j++) {
			        Cell passDescriptionCell = sheet9.getCell(10, j);
			        String passDescription = passDescriptionCell.getContents();
			        textFile.write("String " + passDescription + "();" + "\n");
		       	}
		       	for (int l = 1; l < count9.length; l++) {
			        Cell passWebelementCell = sheet9.getCell(17, l);
			        String passWebelement = passWebelementCell.getContents();
			        textFile.write("String " + passWebelement + "();" + "\n");
		       	}
		       	for (int k = 1; k < count9.length; k++) {
			        Cell passLinkCell = sheet9.getCell(34, k);
			        String passLink = passLinkCell.getContents();
			        textFile.write("String " + passLink + "();" + "\n");
		       	}
		       	for (int l = 1; l < count9.length; l++) {
			        Cell passOracleCell = sheet9.getCell(40, l);
			        String passOracle = passOracleCell.getContents();
			        textFile.write("String " + passOracle + "();" + "\n");
		       	}
	       	}
	       	if (xlsSheet10 > 0  ){
		    	Sheet sheet10 = workbook.getSheet(xlsSheet10);
		    	Cell[] count10 = sheet10.getColumn(0);
		       	for (int i = 1; i < count10.length; i++) {
			        Cell passNameCell = sheet10.getCell(3,i);
			        String passName = passNameCell.getContents();
			        textFile.write("String " + passName + "();" + "\n");
		       	}
		       	for (int j = 1; j < count10.length; j++) {
			        Cell passDescriptionCell = sheet10.getCell(10, j);
			        String passDescription = passDescriptionCell.getContents();
			        textFile.write("String " + passDescription + "();" + "\n");
		       	}
		       	for (int l = 1; l < count10.length; l++) {
			        Cell passWebelementCell = sheet10.getCell(17, l);
			        String passWebelement = passWebelementCell.getContents();
			        textFile.write("String " + passWebelement + "();" + "\n");
		       	}
		       	for (int k = 1; k < count10.length; k++) {
			        Cell passLinkCell = sheet10.getCell(34, k);
			        String passLink = passLinkCell.getContents();
			        textFile.write("String " + passLink + "();" + "\n");
		       	}
		       	for (int l = 1; l < count10.length; l++) {
			        Cell passOracleCell = sheet10.getCell(40, l);
			        String passOracle = passOracleCell.getContents();
			        textFile.write("String " + passOracle + "();" + "\n");
		       	}
	       	}
	       	if (xlsSheet11 > 0  ){
		    	Sheet sheet11 = workbook.getSheet(xlsSheet11);
		    	Cell[] count11 = sheet11.getColumn(0);
		       	for (int i = 1; i < count11.length; i++) {
			        Cell passNameCell = sheet11.getCell(3,i);
			        String passName = passNameCell.getContents();
			        textFile.write("String " + passName + "();" + "\n");
		       	}
		       	for (int j = 1; j < count11.length; j++) {
			        Cell passDescriptionCell = sheet11.getCell(10, j);
			        String passDescription = passDescriptionCell.getContents();
			        textFile.write("String " + passDescription + "();" + "\n");
		       	}
		       	for (int l = 1; l < count11.length; l++) {
			        Cell passWebelementCell = sheet11.getCell(17, l);
			        String passWebelement = passWebelementCell.getContents();
			        textFile.write("String " + passWebelement + "();" + "\n");
		       	}
		       	for (int k = 1; k < count11.length; k++) {
			        Cell passLinkCell = sheet11.getCell(34, k);
			        String passLink = passLinkCell.getContents();
			        textFile.write("String " + passLink + "();" + "\n");
		       	}
		       	for (int l = 1; l < count11.length; l++) {
			        Cell passOracleCell = sheet11.getCell(40, l);
			        String passOracle = passOracleCell.getContents();
			        textFile.write("String " + passOracle + "();" + "\n");
		       	}
		       	if (xlsSheet12 > 0  ){
			    	Sheet sheet12 = workbook.getSheet(xlsSheet12);
			    	Cell[] count12 = sheet12.getColumn(0);
			       	for (int i = 1; i < count12.length; i++) {
				        Cell passNameCell = sheet12.getCell(3,i);
				        String passName = passNameCell.getContents();
				        textFile.write("String " + passName + "();" + "\n");
			       	}
			       	for (int j = 1; j < count12.length; j++) {
				        Cell passDescriptionCell = sheet12.getCell(10, j);
				        String passDescription = passDescriptionCell.getContents();
				        textFile.write("String " + passDescription + "();" + "\n");
			       	}
			       	for (int l = 1; l < count12.length; l++) {
				        Cell passWebelementCell = sheet12.getCell(17, l);
				        String passWebelement = passWebelementCell.getContents();
				        textFile.write("String " + passWebelement + "();" + "\n");
			       	}
			       	for (int k = 1; k < count12.length; k++) {
				        Cell passLinkCell = sheet12.getCell(34, k);
				        String passLink = passLinkCell.getContents();
				        textFile.write("String " + passLink + "();" + "\n");
			       	}
			       	for (int l = 1; l < count12.length; l++) {
				        Cell passOracleCell = sheet12.getCell(40, l);
				        String passOracle = passOracleCell.getContents();
				        textFile.write("String " + passOracle + "();" + "\n");
			       	}
		       	}
	       	}

	       	
	       	textFile.write("String ContextMenuZoomin();\n");
	       	textFile.write("String ContextMenuToggleRoute();\n");
	       	textFile.write("String ContextMenuVideo();\n");
	       	textFile.write("String ContextMenuPictures();\n");
			textFile.write("String ContextMenuThreeSixty();\n");
	       	textFile.write("String ContextMenuBikemap();\n");
	       	textFile.write("String ContextMenuStreetview();\n");
	       	textFile.write("String ContextMenuStreetviewReverse();\n");
	       	textFile.write("String ContextMenuMotorbike();\n");
	       	textFile.write("String ContextMenu3D();\n");
	       	textFile.write("String ContextMenu3DTour();\n");
	       	textFile.write("String ContextMenutourReverse();\n");
	       	textFile.write("String ContextMenuGame();\n");
	       	textFile.write("String ContextMenuClimbbybike();\n");
	       	textFile.write("String ContextMenuZoomout();\n");
	       	textFile.write("String ContextMenuQuaeldich();\n");
	       	textFile.write("String ContextMenuProfile();\n");
	       	textFile.write("String ContextMenuExplore();\n");
	       	textFile.write("\n");
	       	if (cycled == true) {
	       		textFile.write("String EntryDialogTitle();\n");
	       		textFile.write("String EntryDialogShowAgain();\n");
	       		textFile.write("String EntryDialogMessage1();\n");	
	    		textFile.write("String EntryDialogMessage2();\n");		
	    		textFile.write("String EntryDialogMessage3();\n");
	    		textFile.write("\n");
	    		textFile.write("String webElementNews();\n");
	    		textFile.write("String webElementComments();\n");
	    		textFile.write("String webElementProblems();\n");
	    		textFile.write("String webElementMissingPasses();\n");
	    		textFile.write("\n");
	    		textFile.write("String MenuBarPasses2000();\n");
	    		textFile.write("String MenuBarPasses1500();\n");
	    		textFile.write("String MenuBarPasses1000();\n");
	    	    textFile.write("String MenuBarOtherPasses();\n");
	    	    textFile.write("String MenuBarToggleLayers();\n");
	    	    textFile.write("String MenuBarAdditionalInformation();\n");
	    	    textFile.write("String MenuBarComment();\n");
	    	    textFile.write("String MenuBarLatest();\n");
	    	    textFile.write("String MenuBarLanguages();\n");
	    	    textFile.write("String MenuBarEnglish();\n");
	    	    textFile.write("String MenuBarItalian();\n");
	    	    textFile.write("String MenuBarGerman();\n");
	    	    textFile.write("String MenuBarNetherlands();\n");
	    	    textFile.write("String MenuBarSleep();\n");
	    	    textFile.write("String MenuBarImpressum();\n");
	    	    textFile.write("String MenuBarHelp();\n");
	    	    textFile.write("String MenuBarHelpme();\n");
	    	    textFile.write("String MenuBarDisclaimer();\n");
	    	    textFile.write("String MenuBarContact();\n");
	    	    textFile.write("String MenuBarMissingPasses();\n");
	    	    textFile.write("String MenuBarProblems();\n");
	    	    textFile.write("String MenuBarConversation();\n");
	    	    textFile.write("String MenuBarMountains4000();\n");
	    	    textFile.write("\n");
	    	    textFile.write("String news();\n");
	    	    textFile.write("\n");
	    	    textFile.write("String suggest();\n");
	    	    textFile.write("String ReportProblem();\n");
	    	    textFile.write("\n");
	    	    textFile.write("String embed();\n");
	    	    textFile.write("String embedNoPlay();\n");
	    	    textFile.write("String embedHtml();\n");
	    	    textFile.write("\n");
	    	    textFile.write("String OverviewOracle();\n");
	    	    textFile.write("String OverviewLink();\n");
	    	    textFile.write("\n");
	    	    textFile.write("String gameExplanation();\n");
	    	    textFile.write("String GameExplanationShowAgain();\n");
	    	    textFile.write("String GameButton();\n");
	    	    textFile.write("\n");
	    	    textFile.write("String exploreExplanation();\n");
	    	    textFile.write("String Forwards();\n");
	    	    textFile.write("String Backwards();\n");
	    	    textFile.write("String Straferight();\n");
	    	    textFile.write("String Strafeleft();\n");
	    	    textFile.write("String Arrow();\n");
	    	    textFile.write("String Page();\n");
	    	    textFile.write("String ExploreButton();\n");
	    	    
	       	}
	       	textFile.write("}\n");
	    	textFile.close();
	    } catch (BiffException e) {
	      e.printStackTrace();
	    } catch (IOException e) {
	      e.printStackTrace();
	    }
	}

}
